﻿/********************************************************************
FileName    :   Bll_OS.cs
CreateTime  :   2020-11-17 02:19:44
BaseClass   :   Bll_OS
FileType    :   .cs
Author      :  minjie
Description :   Bll_OS层（简单三层）
*********************************************************************/

using System;
using System.Text;
using System.Collections.Generic;

using System.Data;
using OS.DAL;
namespace OS.BLL
{
    /// <summary>
    /// Bll_sys_DICTIONARY的摘要说明。
    /// </summary>
    public partial class Bll_STDjLsh
    {

        private readonly Dal_STDjLsh dal = new Dal_STDjLsh();
        public Bll_STDjLsh()
        { }

        #region  Method 

        public bool Exists(string DjName)
        {
            return dal.Exists(DjName);
        }

        /// <summary> 
        /// 增加一条数据 
        /// </summary> 
        public bool Add(STDjLsh_Entity model)
        {
            return dal.Add(model);
        }

        /// <summary> 
        /// 增加一条数据 
        /// </summary> 
        public string AddStr(STDjLsh_Entity model)
        {
            return dal.AddStr(model);
        }

        /// <summary> 
        /// 更新一条数据 
        /// </summary> 
        public bool Update(STDjLsh_Entity model)
        {
            return dal.Update(model);
        }

        /// <summary> 
        /// 更新一条数据(字符串) 
        /// </summary> 
        public string UpdateStr(STDjLsh_Entity model)
        {
            return dal.UpdateStr(model);
        }

        /// <summary> 
        /// 删除一条数据 
        /// </summary> 
        public bool Delete(string DjName)
        {

            return dal.Delete(DjName);
        }
        /// <summary> 
        /// 批量删除一批数据 
        /// </summary> 
        public bool DeleteList(string lists)
        {
            return dal.DeleteList(lists);
        }
        /// <summary> 
        /// 得到一个对象实体 
        /// </summary> 
        public STDjLsh_Entity GetModel(string DjName)
        {
            return dal.GetModel(DjName);
        }
        public bool Update(string djName)
        {
            return dal.Update(djName);
        }
        /// <summary> 
        /// 获得数据列表 
        /// </summary> 
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary> 
        /// 获得数据count 
        /// </summary> 
        public int GetCount(string strWhere)
        {
            return dal.GetRecordCount(strWhere);
        }

        /// <summary> 
        /// 获得数据列表 
        /// </summary> 
        public List<STDjLsh_Entity> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary> 
        /// 获得数据列表 
        /// </summary> 
        public List<STDjLsh_Entity> GetModelList(string strWhere, string orderby, int startIndex, int endIndex)
        {
            DataSet ds = dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary> 
        /// 获得数据列表 
        /// </summary> 
        public List<STDjLsh_Entity> DataTableToList(DataTable dt)
        {
            List<STDjLsh_Entity> modelList = new List<STDjLsh_Entity>();
            if (dt != null)
            {
                int rowsCount = dt.Rows.Count;
                if (rowsCount > 0)
                {
                    STDjLsh_Entity model;
                    for (int n = 0; n < rowsCount; n++)
                    {
                        model = new STDjLsh_Entity();
                        model.DjName = dt.Rows[n]["DjName"].ToString();

                        if (dt.Rows[n]["DjLsh"] != null && dt.Rows[n]["DjLsh"].ToString() != "")
                            model.DjLsh = int.Parse(dt.Rows[n]["DjLsh"].ToString());


                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }

        /// <summary> 
        /// 获得数据列表 
        /// </summary> 
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary> 
        /// 批量处理 
        /// </summary> 
        public int ExecuteSqlTran(List<string> ls, ref string error)
        {
            return dal.ExecuteSqlTran(ls, ref error);
        }

        /// <summary> 
        /// 直接执行sql语句 
        /// </summary> 
        public int ExecuteSql(string sql)
        {
            return dal.ExecuteSql(sql);
        }

        /// <summary> 
        /// 直接执行sql语句 
        /// </summary> 
        public string GetSingle(string sql)
        {
            return dal.GetSingle(sql);
        }

        /// <summary> 
        /// 直接执行sql语句 
        /// </summary> 
        public DataTable ExecuteDt(string sql)
        {
            return dal.ExecuteDt(sql);
        }

        /// <summary> 
        /// 获取记录总数 
        /// </summary> 
        public int GetRecordCount(string strWhere)
        {
            return dal.GetRecordCount(strWhere);
        }
        #endregion

    }

}
